<template>
  <div>
    <page-main v-loading.fullscreen.lock="loading">
      <div class="head">
        <el-input placeholder="请输入标题" v-model="notice_title" clearable></el-input>
      </div>
      <editor v-model="notice_content" />
      <el-row :gutter="20" style="margin-top: 13px;">
        <el-col :span="2">
          <el-button type="primary" @click="notice_Submit()">提交</el-button>
        </el-col>
        <el-col :span="6">
          <el-button @click="notice_Reset()">重置</el-button>
        </el-col>
      </el-row>
    </page-main>
  </div>
</template>

<script>
import { addNotice, removeNotice } from '@/api/requests/admin.js'
export default {
  data () {
    return {
      loading: false,
      notice_title: '',
      notice_content: '',
    }
  },
  methods: {
    notice_Submit () {
      if (this.notice_title == '' || this.notice_content == '') {
        this.$message({
          message: '标题或内容不能是空的哦',
          type: 'warning'
        })
        return
      }
      this.loading = true
      addNotice(this.notice_title, this.notice_content).then(res => {
        setTimeout(() => {
          if (res.code == 200) {
            this.$message({
              message: '发布公告成功',
              type: 'success'
            });
          }
          this.loading = false

        }, 1000);
      })
    },
    notice_Reset () {
      this.notice_title = ''
      this.notice_content = ''
    }
  },
}
</script>

<style lang="scss" scoped>
.head {
    width: 30vw;
    margin-bottom: 20px;
    span {
        line-height: 40px;
    }
}
</style>